home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 January - Disc 2 / Macworld (1999-01) (Disk 2).dmg / Serious Demos / Symbolic Composer 4.2 / Environment / Projects / Questions & Answers / Q&A Programming Music / Frequency calculations < prev    next >
Lisp/Scheme  |  1998-10-26  |  5KB  |  138 lines

  1. FREQUENCY CALCULATIONS
  2.  
  3. >        In regards to Mary's message and your response about Binarrual Beats, I
  4. >have done some work with the SCOM system in that area.  Remember last
  5. >spring when I was asking you 50 questions a day?  Many were concenring
  6. >tunning issues for this purpose initially.  A while back I made an Excel
  7. >spreadsheet which simplifies working with binarrual beat math.  I have
  8. >attached it here for your reference.  Feel free to post it if you would
  9. >like.  It assumes 12 TET.  It also assumes that the best way to create a
  10. >beat is to bend the two carriers equal distances (x/2)from the intial
  11. >carrier instead of mixing the inital carrier and one that is shifted X Hz.
  12. >This is because the perception of the pitch of the set of two closely tuned
  13. >frequencies is the average of the two.  In other words if you want a 10 Hz
  14. >BB, and you are using A 440 as the carrier, it is better to use 435 and 445
  15. >instead of 440 and 450 for example...
  16. >        Perhaps a good solution would be to write a funciton in which the user
  17. >specified two varibles:  1.) the pitch of the average carrier (either in Hz
  18. >or as a note symbol, though i could see things getting complicated in other
  19. >than 12 TET if it were specified as a note symbol which was dependent upon
  20. >tonality), and 2.)  the desired frequency of the of the binaural beat
  21. >(specfied in Hz or by a further function).
  22. >
  23. >        Given user input of this kind, the funciton could generate two MIDI
  24. >channels which contained MIDI Note On's and Pitch Bend values for the
  25. >creation of the beats. One channel would automatically be panned hard left,
  26. >and the other hard right.  This may be complex to do in the SCOM system
  27. >because it obvously reaches across many of the organizational paradigms of
  28. >the SCOM system.  But as with the rest of the fucntions, perhaps a sort of
  29. >general template function could be written that would gerate all of the
  30. >necessary steps...
  31.  
  32. The score below does just that, and you can add pannings to the voice-base
  33. and voice-beat using controller class and 0 and 127 as panning values.
  34. Here is how to add panning (and have your synths controller setup defined
  35. first).
  36.  
  37. ; basefreq calculation
  38.  
  39. ; ok, lets have 440hz as basefreq which is a 4
  40.  
  41. (setq basefreq 440)
  42.  
  43. ; then calculate the cent difference between 440 hz and 450 hz
  44.  
  45. ; (freq-to-cent (+ basefreq 10) basefreq)
  46.  
  47. ; then define a tonality 10hz-alpha so by converting a cent list of 0 and the
  48. ; above value to a frequency ratio list
  49.  
  50. ; now we have a tonality that if you activate it in basenote a 4 then
  51. ; the two notes on channels 1 and 2 panned left and right will produce
  52. ; frequencies 440 hz and 450 hz (now you have to tweak only 4096 to get
  53. ; the pitch bend responce of your synth to work properly).
  54.  
  55. ; the value 10 here is the required beat frequency
  56.  
  57. (create-tonality 10hz-alpha 
  58.      (cents-to-freqs (list 0 (freq-to-cent (+ basefreq 10) basefreq))))
  59.  
  60. (def-orchestra 'orchestra
  61.    all-instruments (voice)
  62.    voice (voice-base voice-beat)
  63. )
  64.  
  65. (def-section-timesheet sect-a
  66.    ;
  67.    ; timesheet
  68.    ;
  69.    with 1/1       ;1       9      17       25      33    
  70.    ;               +---!---+---!---+---!---+---!---+---!
  71.    tonality       "." (activate-tonality (10hz-alpha a 4 4096))
  72.    voice          "----------------"
  73.    ;
  74.    beat 1/1     ; !---!---!---!---!
  75.    voice-base     "-" '(a) with '(85 75 80 70)
  76.    voice-beat     "-" '(b) with '(85 75 80 70)
  77. )
  78.  
  79. (def-section sect-a
  80.   voice-base
  81.     channel 1
  82.     controller (mu80-controllers
  83.                    panning '((127)))
  84.  
  85.   voice-beat
  86.     channel 2
  87.     controller (mu80-controllers
  88.                    panning '((0)))
  89.  
  90. )
  91.  
  92. (def-tempo 120)
  93.  
  94. ; note that nil here makes it saving the file in the same folder that the
  95. ; source code is in.
  96.  
  97. (play-file-p nil
  98.    all-instruments '(sect-a)
  99. )
  100.  
  101. ; since we know that a 4 = 440 hz
  102. ; we can calculate a multiplicator value by
  103. ;  (/ 440 (note-to-freq 'a 4))
  104. ; now, when we multiplicate the freq returned by note-to-freq it
  105. ; is calibrated to a 4 = 440
  106.  
  107. ; (* (/ 440 (note-to-freq 'a 4)) (note-to-freq 'a 4))
  108. ; --> 439.99999999999994   ; quite passable approximation
  109.  
  110. ; lets test it, what is the frequecy of a 5
  111.  
  112. ; (* (/ 440 (note-to-freq 'a 4)) (note-to-freq 'a 5))
  113. ; --> 879.9999999999999   ; the frequency is doubled, works fine, and also
  114. ; notes in between should work ok, too
  115.  
  116. ; lets define it a function
  117.  
  118. (defun note-to-absolute-freq (note octave)
  119.    (* (/ 440 (note-to-freq 'a 4)) (note-to-freq note octave)))
  120.  
  121. ; now you can call it this way
  122.  
  123. (note-to-absolute-freq 'c 4)
  124. --> 261.6255653005986
  125.  
  126. (note-to-absolute-freq 'e 1)
  127. --> 41.20344461410874
  128.  
  129. ; use this to calculate the base frequency in the above example 
  130.  
  131. ; (setq basefreq (note-to-absolute-freq 'e 1))
  132.  
  133. ; and then activate the tonality on the same base note and the beat
  134. ; frequencies should be working, check out that your synth is transposed
  135. ; to a proper octave, since if you play it on a lower octave then the
  136. ; beat frequency will be 5hz, or octave higher it will be 20hz, so
  137. ; have some happy tweaking...
  138.